package com.ferry.protocol;

import com.ferry.serial.api.SerializerType;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class Heartbeats {

    private static final ByteBuf HEARTBEAT_BUF;

    static {
        ByteBuf buf = Unpooled.buffer(ProtocolHeader.HEADER_SIZE);
        buf.writeShort(ProtocolHeader.MAGIC);
        buf.writeByte(MessageType.HEARTBEAT.getCode());
        buf.writeByte(SerializerType.HESSIAN.getCode());
        buf.writeByte(0);
        buf.writeLong(0);
        buf.writeInt(0);


        HEARTBEAT_BUF = Unpooled.unreleasableBuffer(buf).asReadOnly();
    }

    public static ByteBuf heartbeatContent() {
        return HEARTBEAT_BUF.duplicate();
    }
}
